package com.ruoyi;

import com.ruoyi.common.core.domain.AjaxResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.lang.reflect.InvocationTargetException;

/**
 * **********************
 * * Author: XiaShiLong *
 * * Date  : 2021-03-26 *
 * * Time  : 13:09      *
 * * to    : lz&xm      *
 * **********************
 **/
@RestController
@RequestMapping("/open/dynamic")
@Api("动态资源获取")
public class DynamicListDefaultController {

    private final DynamicListDefaultService service;

    @Autowired
    public DynamicListDefaultController(DynamicListDefaultService service) {
        this.service = service;
    }

    @ApiOperation("获取动态列表")
    @GetMapping("/table/{menuId}/{classPath}")
    public AjaxResult table(@PathVariable Long menuId, @PathVariable String classPath) {
        return AjaxResult.success(service.table(menuId, classPath));
    }

    @ApiOperation("获取查询条件")
    @GetMapping("/getQuery/{menuId}/{classPath}")
    public AjaxResult getQuery(@PathVariable Long menuId, @PathVariable String classPath) {
        return AjaxResult.success(service.getQuery(menuId, classPath));
    }

    @ApiOperation("获取动态表单")
    @GetMapping("/getForm/{menuId}/{classPath}")
    public AjaxResult getForm(@PathVariable Long menuId, @PathVariable String classPath) {
        return AjaxResult.success(service.getForm(menuId, classPath));
    }

    @ApiOperation("hov查询")
    @PostMapping("/hovSearch/{page}/{size}/{hovId}")
    public AjaxResult hovSearch(@PathVariable int page, @PathVariable int size, @PathVariable Long hovId, String searchText) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
        return AjaxResult.success(service.hovSearch(page, size, hovId, searchText));
    }

}
